home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / DISPATCH.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  17KB  |  609 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.8  $
  6. //
  7. // Dispatch functions (crackers) to crack a Windows message and pass control
  8. // to a member function via a pointer (pmf).
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_DISPATCH_H)
  11. #define OWL_DISPATCH_H
  12.  
  13. #if !defined(OWL_DEFS_H)
  14. # include <owl/defs.h>
  15. #endif
  16.  
  17. #if defined(BI_NAMESPACE)
  18. namespace OWL {
  19. #endif
  20.  
  21. //
  22. // class GENERIC
  23. // ~~~~~ ~~~~~~~
  24. // Generic class for casting pointer to objects and pointer to member functions
  25. // Class is not actually defined or implemented anywhere
  26. //
  27. class _CALLCNVN GENERIC;   // Conditionally define to correct calling model
  28.  
  29. #if defined(BI_COMP_MSC)
  30. # pragma pointers_to_members(full_generality, virtual_inheritance)
  31. #endif
  32.  
  33. //
  34. // typedef TAnyPMF
  35. // ~~~~~~~ ~~~~~~~
  36. // generic pointer to member function
  37. //
  38. typedef void (GENERIC::*TAnyPMF)();
  39.  
  40. //
  41. // typedef TAnyDispatcher
  42. // ~~~~~~~ ~~~~~~~~~~~~~~
  43. // all message dispatcher functions take four parameters:
  44. // - reference to an object
  45. // - pointer to member function (signature varies according to the cracking
  46. //   that the function performs)
  47. // - wParam
  48. // - lParam
  49. //
  50. typedef int32 _OWLFUNC (*TAnyDispatcher)(GENERIC&, TAnyPMF, uint, int32);
  51.  
  52. //
  53. // LEGEND: in order to keep dispatcher names from getting too long, the
  54. //         following abbreviations are used. The names are based on the data
  55. //         sizes passed & returned, & which param they come from.
  56. //
  57. // - v   (void return)
  58. // - i   (int)
  59. // - U   (uint)
  60. // - H   (HANDLE) (requires special cracking, uint size)
  61. // - I32 (int32)
  62. // - POINT (TPoint&) (TPoint object constructed)
  63. // - POINTER (void*) (model ambient size)
  64. //
  65. // Possible future cracker encoding
  66. //  Which param:
  67. //  - 1  wParam
  68. //  - 2  lParam
  69. //    How cracked (default to no processing, size of param):
  70. //    - U Ambient size uint (squashed lParam in 16bit land)
  71. //    - L Low 16bit word
  72. //    - H high 16bit word
  73. //
  74. // Custom message crackers are named based on the message they crack
  75. //
  76.  
  77. //----------------------------------------------------------------------------
  78.  
  79. //
  80. // passes lParam as an int32 and returns an int result
  81. //
  82. int32 _OWLFUNC
  83. i_LPARAM_Dispatch(GENERIC& generic,
  84.                   int     (GENERIC::*pmf)(int32),
  85.                   uint     wParam,
  86.                   int32    lParam);
  87.  
  88. //
  89. // passes wParam as a uint and returns an int result
  90. //
  91. int32 _OWLFUNC
  92. i_WPARAM_Dispatch(GENERIC& generic,
  93.                   int     (GENERIC::*pmf)(uint),
  94.                   uint     wParam,
  95.                   int32    lParam);
  96.  
  97. //
  98. // passes wParam as a uint and returns a bool result
  99. //
  100. int32 _OWLFUNC
  101. B_WPARAM_Dispatch(GENERIC& generic,
  102.                   bool     (GENERIC::*pmf)(uint),
  103.                   uint     wParam,
  104.                   int32    lParam);
  105.  
  106. //
  107. // passes wParam as a bool and returns a bool result
  108. //
  109. int32 _OWLFUNC
  110. B_B_Dispatch(GENERIC& generic,
  111.              bool     (GENERIC::*pmf)(bool),
  112.              uint     wParam,
  113.              int32    lParam);
  114.  
  115. //----------------------------------------------------------------------------
  116.  
  117. //
  118. // passes nothing and returns an int32 result
  119. //
  120. int32 _OWLFUNC
  121. I32_Dispatch(GENERIC& generic,
  122.              uint32  (GENERIC::*pmf)(),
  123.              uint,
  124.              int32);
  125.  
  126. //
  127. // passes lParam as an int32 and returns an int32 result
  128. //
  129. int32 _OWLFUNC
  130. I32_LPARAM_Dispatch(GENERIC& generic,
  131.                     int32   (GENERIC::*pmf)(int32),
  132.                     uint,
  133.                     int32    lParam);
  134.  
  135. //
  136. // passes lParam as a uint and returns an int32 result
  137. //
  138. int32 _OWLFUNC
  139. I32_U_Dispatch(GENERIC& generic,
  140.                int32   (GENERIC::*pmf)(uint),
  141.                uint,
  142.                int32    lParam);
  143.  
  144. //
  145. // passes wParam as a uint and lParam as an int32 and returns an int32 result
  146. //
  147. int32 _OWLFUNC
  148. I32_WPARAM_LPARAM_Dispatch(GENERIC& generic,
  149.                            int32   (GENERIC::*pmf)(uint, int32),
  150.                            uint     wParam,
  151.                            int32    lParam);
  152.  
  153. //----------------------------------------------------------------------------
  154.  
  155. //
  156. // passes no arguments and returns a uint result
  157. //
  158. int32 _OWLFUNC
  159. U_Dispatch(GENERIC& generic,
  160.            uint    (GENERIC::*pmf)(),
  161.            uint     wParam,
  162.            int32    lParam);
  163. //
  164. // passes lParam as an int32 and returns a bool result
  165. //
  166. int32 _OWLFUNC
  167. B_LPARAM_Dispatch(GENERIC& generic,
  168.                   bool    (GENERIC::*pmf)(int32),
  169.                   uint     wParam,
  170.                   int32    lParam);
  171.  
  172. //
  173. // passes no arguments and returns a bool result
  174. //
  175. int32 _OWLFUNC
  176. B_Dispatch(GENERIC& generic,
  177.            bool    (GENERIC::*pmf)(),
  178.            uint     wParam,
  179.            int32    lParam);
  180.  
  181. //
  182. // passes lParam as an int32 and returns a uint result
  183. //
  184. int32 _OWLFUNC
  185. U_LPARAM_Dispatch(GENERIC& generic,
  186.                   uint    (GENERIC::*pmf)(int32),
  187.                   uint     wParam,
  188.                   int32    param2);
  189.  
  190. //
  191. // passes nothing and returns a uint32 result
  192. //
  193. int32 _OWLFUNC
  194. U32_Dispatch(GENERIC& generic,
  195.              uint32  (GENERIC::*pmf)(),
  196.              uint,
  197.              int32);
  198.  
  199. //
  200. // passes lParam as a TPoint& and returns a uint result
  201. //
  202. int32 _OWLFUNC
  203. U_POINT_Dispatch(GENERIC& generic,
  204.                  uint    (GENERIC::*pmf)(TPoint&),
  205.                  uint,
  206.                  int32    lParam);
  207.  
  208. //
  209. // passes lParam as a void* and returns a uint result
  210. //
  211. int32 _OWLFUNC
  212. U_POINTER_Dispatch(GENERIC& generic,
  213.                    uint    (GENERIC::*pmf)(void*),
  214.                    uint,
  215.                    int32    lParam);
  216.                        
  217. //
  218. // passes lParam as a void* and returns a bool result
  219. //
  220. int32 _OWLFUNC
  221. B_POINTER_Dispatch(GENERIC& generic,
  222.                    bool    (GENERIC::*pmf)(void*),
  223.                    uint,
  224.                    int32    lParam);
  225.  
  226. //
  227. // passes wParam as a uint and returns a uint result
  228. //
  229. int32 _OWLFUNC
  230. U_U_Dispatch(GENERIC& generic,
  231.              uint    (GENERIC::*pmf)(uint),
  232.              uint    param1,
  233.              int32);
  234.  
  235. //
  236. // passes wParam as a bool and returns a bool result
  237. //
  238. int32 _OWLFUNC
  239. B_B_Dispatch(GENERIC& generic,
  240.              bool    (GENERIC::*pmf)(bool),
  241.              uint    param1,
  242.              int32);
  243.  
  244. //
  245. // Passes param2 as an int and returns bool
  246. //
  247. int32 _OWLFUNC
  248. B_I2_Dispatch(GENERIC& generic,
  249.               bool  (GENERIC::*pmf)(int),
  250.               uint,
  251.               int32    param2);
  252.  
  253. //
  254. // passes wParam as a bool and returns a uint result
  255. //
  256. int32 _OWLFUNC
  257. U_B_Dispatch(GENERIC& generic,
  258.              uint    (GENERIC::*pmf)(bool),
  259.              uint     param1,
  260.              int32);
  261.  
  262. //
  263. // passes wParam as bool, lParam as a uint and returns a bool result
  264. //
  265. int32 _OWLFUNC
  266. B_B_U_Dispatch(GENERIC& generic,
  267.              bool    (GENERIC::*pmf)(bool, uint),
  268.              uint     wParam,
  269.              int32    lParam);
  270.  
  271. //
  272. // passes wParam as a uint, lParam as a uint and returns a uint
  273. //
  274. int32 _OWLFUNC
  275. U_U_U_Dispatch(GENERIC& generic,
  276.              uint    (GENERIC::*pmf)(uint, uint),
  277.              uint,
  278.              int32    lParam);
  279.  
  280. //
  281. // passes wParam as a bool, lParam as a uint and returns a uint
  282. //
  283. int32 _OWLFUNC
  284. U_B_U_Dispatch(GENERIC& generic,
  285.              uint    (GENERIC::*pmf)(bool, uint),
  286.              uint,
  287.              int32    lParam);
  288.  
  289. //
  290. // passes wParam as a uint, lParam as a uint and returns a bool
  291. //
  292. int32 _OWLFUNC
  293. B_U_U_Dispatch(GENERIC& generic,
  294.              bool    (GENERIC::*pmf)(uint, uint),
  295.              uint,
  296.              int32    lParam);
  297.  
  298. //
  299. // passes wParam as a uint, lParam as a far pointer to a rect, copying to a
  300. // temp rect & back, if needed for near data models only.  returns uint
  301. //
  302. int32 _OWLFUNC
  303. U_U_RECT_Dispatch(GENERIC& generic,
  304.                   uint    (GENERIC::*pmf)(uint, TRect&),
  305.                   uint     param1,
  306.                   int32    param2);
  307.  
  308. //
  309. // passes wParam as a uint, lParam as a far pointer to a rect, copying to a
  310. // temp rect & back, if needed for near data models only.  returns bool
  311. //
  312. int32 _OWLFUNC
  313. B_U_RECT_Dispatch(GENERIC& generic,
  314.                   bool    (GENERIC::*pmf)(uint, TRect&),
  315.                   uint     param1,
  316.                   int32    param2);
  317.  
  318. //
  319. // passes wParam as a uint, lParam.lo as a uint, and lParam.hi as a uint
  320. //
  321. int32 _OWLFUNC
  322. U_U_U_U_Dispatch(GENERIC& generic,
  323.                  uint    (GENERIC::*pmf)(uint, uint, uint),
  324.                  uint     wParam,
  325.                  int32    lParam);
  326.  
  327. //
  328. // passes wParam as a uint, lParam.lo as a uint, and lParam.hi as a uint
  329. // and returns a bool
  330. int32 _OWLFUNC
  331. B_U_U_U_Dispatch(GENERIC& generic,
  332.                  bool    (GENERIC::*pmf)(uint, uint, uint),
  333.                  uint     wParam,
  334.                  int32    lParam);
  335.  
  336. //
  337. // passes wParam as a uint and lParam as an int32 and returns a uint result
  338. //
  339. int32 _OWLFUNC
  340. U_WPARAM_LPARAM_Dispatch(GENERIC& generic,
  341.                          uint    (GENERIC::*pmf)(uint, int32),
  342.                          uint     wParam,
  343.                          int32    lParam);
  344.  
  345. //
  346. // passes wParam as a uint and lParam as an int32 and returns a bool result
  347. //
  348. int32 _OWLFUNC
  349. B_WPARAM_LPARAM_Dispatch(GENERIC& generic,
  350.                          uint    (GENERIC::*pmf)(uint, int32),
  351.                          uint     wParam,
  352.                          int32    lParam);
  353.  
  354. //
  355. // passes wParam as a bool and lParam as an int32 and returns a uint result
  356. //
  357. int32 _OWLFUNC
  358. U_B_LPARAM_Dispatch(GENERIC& generic,
  359.                     uint    (GENERIC::*pmf)(bool, int32),
  360.                     uint     wParam,
  361.                     int32    lParam);
  362.  
  363. //----------------------------------------------------------------------------
  364.  
  365. //
  366. // passes nothing and always returns 0
  367. //
  368. int32 _OWLFUNC
  369. v_Dispatch(GENERIC& generic,
  370.            void    (GENERIC::*pmf)(),
  371.            uint,
  372.            int32);
  373.  
  374. //
  375. // passes lParam as an int32 and always returns 0
  376. //
  377. int32 _OWLFUNC
  378. v_LPARAM_Dispatch(GENERIC& generic,
  379.                   void    (GENERIC::*pmf)(int32),
  380.                   uint,
  381.                   int32    lParam);
  382.  
  383. //
  384. // passes lParam as a TPoint& and always returns 0
  385. //
  386. int32 _OWLFUNC
  387. v_POINT_Dispatch(GENERIC& generic,
  388.                  void    (GENERIC::*pmf)(TPoint&),
  389.                  uint,
  390.                  int32    lParam);
  391.  
  392. //
  393. // passes lParam as a void* and always returns 0
  394. //
  395. int32 _OWLFUNC
  396. v_POINTER_Dispatch(GENERIC& generic,
  397.                    void    (GENERIC::*pmf)(void*),
  398.                    uint,
  399.                    int32    lParam);
  400.  
  401. //
  402. // passes lParam as a uint and always returns 0
  403. //
  404. int32 _OWLFUNC
  405. v_U_Dispatch(GENERIC& generic,
  406.              void    (GENERIC::*pmf)(uint),
  407.              uint,
  408.              int32    lParam);
  409.  
  410. //
  411. // passes wParam as a uint and lParam as a TPoint& and always returns 0
  412. //
  413. int32 _OWLFUNC
  414. v_U_POINT_Dispatch(GENERIC& generic,
  415.                    void    (GENERIC::*pmf)(uint, TPoint&),
  416.                    uint     wParam,
  417.                    int32    lParam);
  418.  
  419. //
  420. // passes wParam as a uint and lParam as a uint and always returns 0
  421. //
  422. int32 _OWLFUNC
  423. v_U_U_Dispatch(GENERIC& generic,
  424.                void    (GENERIC::*pmf)(uint, uint),
  425.                uint     wParam,
  426.                int32    lParam);
  427.  
  428. //
  429. // passes wParam as a uint and lParam as a bool and always returns 0
  430. //
  431. int32 _OWLFUNC
  432. v_U_B_Dispatch(GENERIC& generic,
  433.                void    (GENERIC::*pmf)(uint, bool),
  434.                uint     wParam,
  435.                int32    lParam);
  436.  
  437. //
  438. // passes wParam as a bool and lParam as a uint and always returns 0
  439. //
  440. int32 _OWLFUNC
  441. v_B_U_Dispatch(GENERIC& generic,
  442.                void    (GENERIC::*pmf)(bool, uint),
  443.                uint     wParam,
  444.                int32    lParam);
  445.  
  446. //
  447. // passes wParam as a uint, lParam.lo as a uint, and lParam.hi as a uint and
  448. // always returns 0
  449. //
  450. int32 _OWLFUNC
  451. v_U_U_U_Dispatch(GENERIC& generic,
  452.                  void    (GENERIC::*pmf)(uint, uint, uint),
  453.                  uint     wParam,
  454.                  int32    lParam);
  455.  
  456. //
  457. // passes wParam as a bool, lParam.lo as a uint, and lParam.hi as a uint and
  458. // always returns 0
  459. //
  460. int32 _OWLFUNC
  461. v_B_U_U_Dispatch(GENERIC& generic,
  462.                  void    (GENERIC::*pmf)(bool, uint, uint),
  463.                  uint     wParam,
  464.                  int32    lParam);
  465.  
  466. //
  467. // passes wParam as a uint, lParam.lo as a uint, and lParam.hi as a bool and
  468. // always returns 0
  469. //
  470. int32 _OWLFUNC
  471. v_U_U_B_Dispatch(GENERIC& generic,
  472.                  void    (GENERIC::*pmf)(uint, uint, bool),
  473.                  uint     wParam,
  474.                  int32    lParam);
  475.  
  476. //
  477. // passes wParam as a uint and always returns 0
  478. //
  479. int32 _OWLFUNC
  480. v_WPARAM_Dispatch(GENERIC& generic,
  481.                   void    (GENERIC::*pmf)(uint),
  482.                   uint     wParam,
  483.                   int32    lParam);
  484.  
  485. #if defined(BI_PLAT_WIN32)
  486. //
  487. // passes wParam as an HWND and lParam as a pointer and always returns true
  488. // for WM_COPYDATA
  489. //
  490. int32 _OWLFUNC
  491. v_HWND_PCOPYDATASTRUCT_Dispatch(GENERIC& generic,
  492.                          void    (GENERIC::*pmf)(HWND, COPYDATASTRUCT*),
  493.                          uint     wParam,
  494.                          int32    lParam);
  495. #endif
  496.  
  497. //
  498. // passes wParam as a bool and always returns 0
  499. //
  500. int32 _OWLFUNC
  501. v_B_Dispatch(GENERIC& generic,
  502.              void    (GENERIC::*pmf)(bool),
  503.              uint     wParam,
  504.              int32    lParam);
  505.  
  506. //
  507. // passes wParam and lParam as bools and always returns 0
  508. //
  509. int32 _OWLFUNC
  510. v_B_B_Dispatch(GENERIC& generic,
  511.              void    (GENERIC::*pmf)(bool, bool),
  512.              uint     wParam,
  513.              int32    lParam);
  514.  
  515. //
  516. // passes wParam as a uint and lParam as an int32 and always returns 0
  517. //
  518. int32 _OWLFUNC
  519. v_WPARAM_LPARAM_Dispatch(GENERIC& generic,
  520.                          void    (GENERIC::*pmf)(uint, int32),
  521.                          uint     wParam,
  522.                          int32    lParam);
  523.  
  524.  
  525. //----------------------------------------------------------------------------
  526. // Semi-custom crackers
  527.  
  528. //
  529. // passes a uint, Handle, and uint and returns an int result
  530. // 32-bit: wParam.lo, lParam,    wParam.hi
  531. // 16-bit: wParam,    lParam.lo, lParam.hi
  532. //
  533. int32 _OWLFUNC
  534. i_U_W_U_Dispatch(GENERIC& generic,
  535.                  int     (GENERIC::*pmf)(uint, uint, uint),
  536.                  uint     wParam,
  537.                  int32    lParam);
  538.  
  539. //
  540. // passes two uints and a HANDLE and always returns 0
  541. // 32-bit passes: wParam.lo, wParam.hi, lParam
  542. // 16-bit passes: wParam,    lParam.lo, lParam.hi (same as v_U_U_U)
  543. //
  544. int32 _OWLFUNC
  545. v_U_U_W_Dispatch(GENERIC& generic,
  546.                  void    (GENERIC::*pmf)(uint, uint, uint),
  547.                  uint     wParam,
  548.                  int32    lParam);
  549.  
  550. //----------------------------------------------------------------------------
  551. // message-specific crackers
  552.  
  553. //
  554. // cracker for WM_ACTIVATE
  555. // passes a uint, a bool, and an HWND and always returns 0
  556. //
  557. int32 _OWLFUNC
  558. v_Activate_Dispatch(GENERIC& generic,
  559.                     void    (GENERIC::*pmf)(uint, bool, uint),
  560.                     uint     wParam,
  561.                     int32    lParam);
  562.  
  563. //
  564. // cracker for WM_MDIACTIVATE
  565. // passes two HWNDs and always returns 0
  566. //
  567. int32 _OWLFUNC
  568. v_MdiActivate_Dispatch(GENERIC& generic,
  569.                        void    (GENERIC::*pmf)(uint, uint),
  570.                        uint     wParam,
  571.                        int32    lParam);
  572.  
  573.  
  574. //
  575. // cracker for WM_PARENTNOTIFY
  576. // passes two uints and an HWND and returns a 32bit result
  577. //
  578. int32 _OWLFUNC
  579. I32_MenuChar_Dispatch(GENERIC& generic,
  580.                       int32   (GENERIC::*pmf)(uint, uint, uint),
  581.                       uint     wParam,
  582.                       int32    lParam);
  583.  
  584. //
  585. // cracker for WM_PARENTNOTIFY
  586. // passes three uints and always returns 0
  587. //
  588. int32 _OWLFUNC
  589. v_ParentNotify_Dispatch(GENERIC& generic,
  590.                         void    (GENERIC::*pmf)(uint, uint, uint),
  591.                         uint     wParam,
  592.                         int32    lParam);
  593.  
  594. #if defined(BI_NAMESPACE)
  595. } // namespace OWL
  596. #endif
  597.  
  598.  
  599. //----------------------------------------------------------------------------
  600. // Aliases for compatibility
  601.  
  602. #define HBRUSH_HDC_W_U_Dispatch  U_U_U_U_Dispatch
  603. #define LRESULT_U_U_W_Dispatch   I32_MenuChar_Dispatch
  604. #define LRESULT_WPARAM_LPARAM_Dispatch I32_WPARAM_LPARAM_Dispatch
  605. #define v_U_B_W_Dispatch         v_Activate_Dispatch
  606. #define v_W_W_Dispatch           v_MdiActivate_Dispatch
  607.  
  608. #endif  // OWL_DISPATCH_H
  609.